export class ArrayHelpa<T>{
    constructor(private arr:T[]){

    }
    take(n:number):T[]{
        if(n>=this.arr.length){
            return this.arr
        }
        else{
            const  newArray:T[] = [];
            for (let index = 0; index < n; index++) {
                const element = this.arr[index];
                newArray.push(element)
                
            }
            return newArray
        }
    
    }
   
    shuffle(arr:T[]):T[]{
        for (let index = 0; index < this.arr.length; index++) {
            const element = this.arr[index];
            const targetIndex = this.getRandom(0,this.arr.length)
            this.arr[index] = this.arr[targetIndex];
            this.arr[targetIndex] = element
         
            
        }
       return this.arr
    }
    getRandom(max:number,min:number):number{
        return Math.floor(Math.random()*(max-min)+min)
    }
}